package com.utils;

import java.io.File;
import java.util.UUID;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.multipart.MultipartFile;

public class Util {

	public static String getUUID() {
		String uuid = UUID.randomUUID().toString();
		return uuid;
	}

	public static boolean makeDir(String targetdir){
		File dir = new File(targetdir);
		boolean isExitDir = true;
		if (!dir.exists() && !dir.isDirectory()) {
			if (dir.mkdirs()) {
			} else {
			}
			isExitDir = false;
		}
		return isExitDir;
	}

	public static void transferDoc(MultipartFile file, String docName, String targetdir) {
		makeDir(targetdir);
		String path = targetdir + docName;
		try {
			file.transferTo(new File(path));
		} catch (Exception e) {
		}
	}
}
